<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Koperasi Rumah Sakit Haji Surabaya</title>
</head>
<body>
<table border="0" align="center">
<tr><th>DAFTAR SIMPANAN ANGGOTA</th></tr>
<tr><th>KOPERASI RUMAH SAKIT HAJI SURABAYA</th></tr>
<tr><th>PERIODE : JANUARI <?php echo $tahun;?> s/d DESEMBER <?php echo $tahun; ?> </th></tr>
</table>
</br>
</br>
<table border="1" align="center">
<tr>
<th rowspan="2">NO.</th>
<th rowspan="2">NO.ANGGOTA</th>
<th rowspan="2">NAMA</th>
<th rowspan="2">JUMLAH SIMPANAN TAHUN <?php echo $tahun-1;?></th>
<th colspan="2">MUTASI SIMPANAN TAHUN <?php echo $tahun;?></th>
<th rowspan="2">JUMLAH TOTAL SIMPANAN</th>
</tr>
<tr>
<th>POKOK</th>
<th>WAJIB</th> 
</tr>
<?php 
$no = 1;
foreach($data as $row){
$model = Anggota::model()->find("ID_ANGGOTA=".$row['id']);
$model_past = HistoryTabungan::model()->findAll('YEAR(TANGGAL_TRANSAKSI)='.($tahun-1).' AND ID_ANGGOTA='.$row['id']);
$total_past = 0;
foreach($model_past as $data_past){
	$total_past = $total_past + $data_past->JUMLAH;
}
?>
<tr>
<td>
<?php echo $no;
$no=$no+1;?>
</td>
<td>
<?php echo $model->NO_ANGGOTA;?>
</td>
<td>
<?php echo $model->NAMA;?>
</td>
<td>
<?php echo "Rp ".number_format($total_past,2,",",".");?>
</td>
<td>
<?php echo "Rp ".number_format($row['pokok'],2,",",".");?>
</td>
<td>
<?php echo "Rp ".number_format($row['wajib'],2,",",".");?>
</td>
<td>
<?php echo "Rp ".number_format($total_past+$row['pokok']+$row['wajib'],2,",",".");?>
</td>
</tr>
<?php
}
?>
</table>
</body>
</html>